#ifndef __STATICDATA_ATOMSTRING_H__
#define __STATICDATA_ATOMSTRING_H__

#include <string>
#include <vector>

class ProxyString;
class AtomString
{
public:
	AtomString() : m_nIndex(size_t(-1))
	{
	}
	AtomString(const std::string &s) : m_nIndex(size_t(-1))
	{
		SetString(s);
	}
	void SetString(const std::string &s)
	{
		size_t nIndex = _Find(s);
		if (nIndex == size_t(-1))
		{
			nIndex = _Add(s);
		}
		if (nIndex != m_nIndex)
		{
			m_nIndex = nIndex;
		}
	}
	bool operator == (const AtomString &rhs) const
	{
		return m_nIndex != size_t(-1) && m_nIndex == rhs.m_nIndex;
	}
	bool operator < (const AtomString &rhs) const
	{
		return m_nIndex < rhs.m_nIndex;
	}
	operator size_t() const
	{
		return m_nIndex;
	}
protected:
	static size_t _Find(const std::string &s);
	static size_t _Add(const std::string &s);
	static std::vector<ProxyString> s_vecProxyString;

	size_t m_nIndex;
};

#endif //__STATICDATA_ATOMSTRING_H__
